﻿package {
	import com.kerry.effect.PowerFilters;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.display.LoaderInfo;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.net.URLRequest;
	/**
	 * com.kerry.effect.PowerFilters 类的演示文件
	 * @author PhoenixKerry（http://blog.sina.com.cn/yyy98）
	 */
	public class PowerFiltersDemo extends Sprite {
		private var bitmapData:BitmapData;
		private var bitmap:Bitmap;
		private var counter:uint = 100;
		
		public function PowerFiltersDemo() {
			var loader:Loader = new Loader();
			addChild(loader);
			loader.load(new URLRequest("../assets/demo.jpg"));
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
		}
		
		private function onImageLoaded(e:Event):void {
			var loaderInfo:LoaderInfo = e.target as LoaderInfo;
			bitmap = loaderInfo.content as Bitmap;
			bitmapData = bitmap.bitmapData;
			
			// === DisplayObject Filters ===
			PowerFilters.grayFilter(bitmap);
			//PowerFilters.lightingFilter(bitmap, 150);
			//PowerFilters.blurFilter(bitmap);
			//PowerFilters.raiseFilter(bitmap);
			//PowerFilters.embossFilter(bitmap);
			//PowerFilters.sharpenFilter(bitmap, 10);
			//PowerFilters.oldPictureFilter(bitmap);
			//PowerFilters.diffuseFilter(bitmap,30,20);
			//PowerFilters.waterColorFilter(bitmap, 30, 20);
			//PowerFilters.saturation(bitmap,1,300);
			//PowerFilters.colorTrans(bitmap, 128);
			//PowerFilters.removeAllFilters(bitmap);
			
			// === BitmapData Filters ===
			//PowerFilters.noiseFilter(bitmapData, 180);
			//PowerFilters.sketchFilter(bitmapData, 10);
			//PowerFilters.pinchFilter(bitmapData, 14);
			//PowerFilters.illuminateFilter(bitmapData, 250, 0.5, 0.8, 70);
			//PowerFilters.mosaicFilter(bitmapData, 9);
			//PowerFilters.oilPaintingFilter(bitmapData);
			//PowerFilters.thresholdFilter(bitmapData, 128);
		}
		
	}
}